package com.codeZ.VisitiorPattern;

import java.util.ArrayList;
import java.util.List;

/**
 * 操作类
 *
 * @author codeZhang
 * @Date 2024/8/29 17:03
 */
public class ObjectStructure {

    private final List<Element> elements = new ArrayList<Element>();


    public void attach(Element element){
        elements.add(element);
    }

    public void detach(Element element){
        elements.remove(element);
    }

    public void accept(Visitor visitor){
        for (Element element : elements) {
            element.accept(visitor);
        }
    }


}
